package com.kiki.stater;

import java.util.ArrayList;

/**
 * Created by mazeyi on 2020/9/16.
 */
public class Demo {
    private static volatile boolean flag = true;

    static class Thread1 extends Thread{
        @Override
        public void run(){
            while (flag){
                System.out.println(111);
            }
            System.out.println("thread1-run");
        }
    }

    static class Thread2 extends Thread{
        @Override
        public void run(){
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("thread1-run");
            flag = false;
            System.out.println("flag 修改为false");
        }
    }


    public static void main(String[] args)  {
        ArrayList<String> list =  new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        for(int i = 0;i<list.size();i++){
            if(list.get(i).equals("c")){
                list.remove(i);
            }
            System.out.println(list);
        }
//        for(String str : list){
//            list.remove(str);
//        }
//
       // Cleaner cleaner = new Cleaner();
    }
}

